//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Core.h".
//-------------------------------------------------------------------

#ifndef _UXS_LIBC_CDEFS_H
#define _UXS_LIBC_CDEFS_H

#pragma once

/* jit64 instrinsic stuff */
#ifndef _CRT_JIT_INTRINSIC
# if defined(_M_CEE) && (defined(_M_AMD64) or defined(_M_IA64))
   /* This is only needed when managed code is calling the native APIs, targeting the 64-bit runtime */
#  define _CRT_JIT_INTRINSIC	__declspec( jitintrinsic )
# else
#  define _CRT_JIT_INTRINSIC 
# endif
#endif


#if !defined(__CDECL)
# if defined(_M_CEE_PURE)
#  define __CDECL
# else
#  define __CDECL   __cdecl
# endif
#endif


#ifdef COMPILER_MSVC
#	define __INT64			__int64
#else
#	define __INT64			long long
#endif


#ifdef  PLATFORM_64BIT
// 64 bit
# ifndef _SIZE_T_DEFINED
	typedef unsigned __INT64	size_t;
#	define _SIZE_T_DEFINED
# endif

# ifndef _SIZE_T_DEFINED
	typedef signed __INT64		ssize_t;
#	define _SIZE_T_DEFINED
# endif

	typedef __INT64				ptrdiff_t;

# ifndef _INTPTR_T_DEFINED
#	define _INTPTR_T_DEFINED
	typedef __INT64				intptr_t;
# endif

# ifndef _UINTPTR_T_DEFINED
#	define _UINTPTR_T_DEFINED
	typedef unsigned __INT64	uintptr_t;
# endif

#else

// 32 bit
# ifndef _SIZE_T_DEFINED
	typedef unsigned int		size_t;
#	define _SIZE_T_DEFINED
# endif

# ifndef _SSIZE_T_DEFINED_
	typedef signed int			ssize_t;
#	define _SSIZE_T_DEFINED_
# endif
	
	typedef int					ptrdiff_t;
	
# ifndef _INTPTR_T_DEFINED
#	define _INTPTR_T_DEFINED
	typedef int					intptr_t;
# endif
	
# ifndef _UINTPTR_T_DEFINED
#	define _UINTPTR_T_DEFINED
	typedef unsigned int		uintptr_t;
# endif

#endif
	

#ifndef _OFF_T_DEFINED
	typedef long _off_t;                    /* file offset value */

#	if 1 //!__STDC__
		/* Non-ANSI name for compatibility */
		typedef long off_t;
#	endif

#	define _OFF_T_DEFINED
#endif
		

#ifndef _DEV_T_DEFINED
	typedef unsigned int _dev_t;            /* device code */

#	if 1 //!__STDC__
		/* Non-ANSI name for compatibility */
		typedef unsigned int dev_t;
#	endif

#	define _DEV_T_DEFINED
#endif

	
#ifndef _INO_T_DEFINED
	typedef unsigned short _ino_t;          /* i-node number (not used on DOS) */

#	if 1 //!__STDC__
		/* Non-ANSI name for compatibility */
		typedef unsigned short ino_t;
#	endif

#	define _INO_T_DEFINED
#endif

		
#ifndef _TIME32_T_DEFINED
	typedef long __time32_t;   /* 32-bit time value */
#	define _TIME32_T_DEFINED
#endif
		
#ifndef _TIME64_T_DEFINED
	typedef long long __time64_t;     /* 64-bit time value */
#	define _TIME64_T_DEFINED
#endif

#ifndef _TIME_T_DEFINED
#	ifdef _USE_32BIT_TIME_T
		typedef __time32_t time_t;      /* time value */
#	else
		typedef __time64_t time_t;      /* time value */
#	endif
#	define _TIME_T_DEFINED         /* avoid multiple def's of time_t */
#endif


#if defined(PLATFORM_WINDOWS) && defined(COMPILER_MSVC)
/*
 * Currently, all MS C compilers for Win32 platforms default to 8 byte
 * alignment.
 */
#undef  __PACKING
#define __PACKING 8

#endif	// PLATFORM_WINDOWS && COMPILER_MSVC


#endif	// _UXS_LIBC_CDEFS_H